//封装查看滚动条的距离
   function getScrollOffset(){
       if(window.pageXOffset){
         return {
           left:window.pageXOffset,
           top:window.pageYOffset,
         }
       }else {
           return {
               left:document.body.scrollLeft + document.documentElement.scrollLeft,
               top:document.body.scrollTop + document.documentElement.scrollTop,
           }
       }
   }

//封装取消冒泡并兼容IE
     function eleBudder(e){
       var e = e || window.event;
       if(e.stopPropagation){
         e.stopPropagation();
       }else{
         e.cancelBuddle = true;
       }
     }

//封装阻止默认事件兼容性
function preventDefaultEvent(e){
    var e  = e || window.event;
    if(e.preventDefault){
     e.preventDefault();
    }else {
        e.returnValue = false ;
    }
}
//封装注册/绑定事件处理函数及兼容版本
      function addEvent(el,type,fn){
          if(el.addEventListener){
              el.addEventListener(type, fn, false);
          }else if(el.attachEvent){
              el.attachEvent('on' + type, function(){
                  fn.call(el);
              })
          }else {
              el['on' + type]= fn;
          }
      }
//封装取消注册事件/移除事件处理处理函数兼容
    function removeEvent(el,type,fn){
          if(el.addEventListener){
              el.removeEventListener(type, fn, false);
          }else if(el.attachEvent){
              el.detachEvent('on' + type, function(){
                  fn.call(el);
              })
          }else {
              el['on' + type]= null;
          }
      } 

//封装浏览器可视区域的尺寸(窗口的宽高)怪异模式和标准模式并兼容IE9及IE8
      function getViewportSize(){
           if(window.innerWidth){ //常规状态下
               return {
                   width: window.innerWidth, //包括滚动条
                   height:window.innerHeight,
               }
           }else{
               if(document.compatMode === 'BackCompat'){
                return {
                    width:document.body.clientWidth, //包括滚动条
                    height:document.body.clientHeight,
                }
               }else {
                   return {
                       width:document.documentElement.clientWidth, //不包括
                       height:document.documentElement.clientHeight,
                   }
               }
           }
       }
//封装查看元素属性(宽高)兼容IE9及IE8
   function getStyles(elem, prop){
    if(window.getComputedStyle){
        if(prop){
            return parseInt(window.getComputedStyle(elem, null)[prop]); //null 是为放伪元素而存在的
        }else {
            return window.getComputedStyle(elem, null);
        }
      }else {
          if(prop){
              return parseInt(elem.styleCurrent.prop);
          }else {
              return elem.styleCurrent;
          }
      }
   }
 //封装监测整个html文档的大小
 /* 
  *scrollWidth = window.innerWidth + window.pageXoffset;
 */ 
       function getscrollSize(){
           if(document.body.scrollWidth){
             return {
                 width: document.body.scrollWidth,
           height: document.body.scrollHeight,
             }
           }else {
         return {
             width:document.documentElement.scrollWidth,
             height:document.documentElement.scrollHeight,
         }
           }
       }

// 封装鼠标位置坐标pageX/Y兼容性
function pagePos(e){
   var sLeft = getScrollOffset().left,
       sTop = getScrollOffset().top,
       cLeft = document.documentElement.clientLeft || 0,
       cTop = document.documentElement.clientTop || 0 ;

     return {
         X:e.clientX + sLeft - cLeft,
         Y:e.clientY + sTop - cTop,
     }
}

